package com.atguigu.lease.web.app.context;

import com.atguigu.lease.model.entity.SystemUser;
import com.atguigu.lease.model.entity.UserInfo;

//主要的作用是共享用户信息
public class LoginUserContext {

    //使用ThreadLocal对象时 切记销毁!!  不归类管理  归JVM管理
    private static ThreadLocal<UserInfo> threadLocal = new ThreadLocal<>();

    public static UserInfo getUser() {

        return threadLocal.get();
    }

    public static void setUser(UserInfo user) {
        threadLocal.set(user);
    }

    public static void removeUser(){
        threadLocal.remove();
    }
}
